<?

//Initiate Authenticate
SecurityRedirect ();

//initiate Vars 
define("PRIMARY_KEY","kdcust");
$KEY[]         = array("PRIMARY_KEY"=>PRIMARY_KEY);
$FileName      = "ais_transaction_cashbankreceived.php";
$FileTemplate  = "ais_transaction_cashbankreceived_memolist.html";

$PageSize      = 10 ;
$TableName     = "ais_hutang";
$HTMLGridList  = "CustomerGrid";
//************ FORM ACTION **************
	if (GetParam("Action","")=="Delete") {
		DeleteRecord ("txtCheck",$PageSize);
	}

$FCode = GetParam("memorialCodeSearch","");
print "DEbuging Mode On";
//Initiate Database Table For Search;
//******* DATABASE FORM QUERY ***********
include("./sql_stored/ais_transaction_cashbankreceived_pay_sql.php");
SelectTmpMemoTrans();
$SQL      = "SELECT $TableName.* FROM $TableName LEFT JOIN ais_cbtrans_hutang ON $TableName.nobkt=ais_cbtrans_hutang.nobkt WHERE ifnull(ais_cbtrans_hutang.nobkt,'')='' AND $TableName.debtur='".GetParam("debtur","")."' AND $TableName.nobkt like 'ND%'";
$SQLCount = "SELECT count(*) FROM $TableName LEFT JOIN ais_cbtrans_hutang ON $TableName.nobkt=ais_cbtrans_hutang.nobkt WHERE ifnull(ais_cbtrans_hutang.nobkt,'')='' AND $TableName.debtur='".GetParam("debtur","")."' AND $TableName.nobkt like 'ND%'";
//print $SQL;

//******* SHOW FORM CONTENT *********
//$SQL .= "GROUP BY $TableName.nobkt ";
//$SQLCount .= " GROUP BY $TableName.nobkt ";


$PageNum = 1;
$RecCnt = $DBConnection->GetResSQL ($SQLCount);
if (GetParam("PageNum","")) $PageNum  = GetParam("PageNum","");

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate($MOD_TEMPLATE_DIR."/".$FileTemplate);
$TBS->MergeBlock("bln",$KEY);
$TBS->MergeBlock("blg",$DBMysql,$SQL,$PageSize,$PageNum,$RecCnt);

$TBS->MergeNavigationBar('nv',array('size'=>10,'pos'=>'centred'),$PageNum,$RecCnt,$PageSize) ; 
$TBS->Show();


function DeleteRecord ($sequence_name,$PageSize) {
	global $DBConnection,$FileName;	
	for ($x=1;$x<=$PageSize;$x++) {		
		if (GetParam($sequence_name.$x,""))	{
			$DBConnection->Delete("tblcustomer",$sequence_name.$x);
	    }
	}
	header("Location: $FileName");
	exit;	
	
}

?>